// 注意目录，目录可以自定义
import { BookInfo } from './model/BookInfo';

import { Database } from '@hw-agconnect/cloud/src/main/ets/database/Database';
const TAG ="xiadewang"
export async function upsert () {

  try {
/*    const record = await cloud.database({objectTypeInfo: schema, zoneName: "Demo"}).collection(BookInfo).upsert({
      "id":2000,
      "bookName" : "book_name",
      "author" : "huawei",
      "price" : 1020
    });*/
    const record = AppStorage.Get<Database>('agcDataBase').collection(BookInfo).upsert({
      "id":2000,
      "bookName" : "book_name",
      "author" : "huawei",
      "price" : 1020});

    console.info(TAG, "upsert success, record  = " + record);
  } catch (err) {
    console.error(TAG, "upsert err------------" + JSON.stringify(err));
  }
}